import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:奇数位丢弃
 * User: wangxin
 * Date: 2024-10-18
 * Time: 22:44
 */
public class test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n + 1];
            for(int i = 0;i< arr.length;i++){
                arr[i] = i;
            }
            int m = arr.length;
            while(m != 1){
                for(int i = 0; i < arr.length;i++){
                    if((i + 1) % 2 != 0){
                        arr[i] = 1001;
                    }
                }
                m = m / 2;
                Arrays.sort(arr);
            }
            System.out.println(arr[0]);
        }
    }
}
